import { List, Button, WhiteSpace, WingBlank } from 'antd-mobile';
import { Component } from 'react'
import Link from 'umi/link';
import { connect } from 'dva';
import { getTenantid, removeToken } from '@/utils/auth';
import router from 'umi/router';
import { mobileFilter } from '@/utils'

const { Item } = List
@connect(({ manager, loading }) => {
  return {
    manager,
  }
})
class Center extends Component {
  constructor(props) {
    super(props)
    this.loginOut = this.loginOut.bind(this)
  }
  componentDidMount() {
    this.getUserInfo()
    this.getTenantInfo()
  }
  getUserInfo() {
    const { dispatch } = this.props
    dispatch({
      type: 'manager/getUserInfo'
    })
  }
  getTenantInfo() {
    const { dispatch } = this.props
    dispatch({
      type: 'manager/getTenantInfo'
    })
  }
  loginOut() {
    removeToken()
    router.push(`/${getTenantid()}`)
    
  }
  render() {
    const { manager: { userInfo ={}, tenantInfo={}},match:{params} } = this.props
    return (
      <div>
        <List>
          <Item extra={userInfo.name}>姓名</Item>
          <Item extra={mobileFilter(userInfo.phone)}>手机</Item>
          <Link to={`/user/resetPassword`}><Item arrow="horizontal">修改密码</Item></Link>
        </List>
        <WhiteSpace />
        <List>
          <Item extra={tenantInfo.name}>平台名称</Item>
          <Item extra={<span>{tenantInfo.totalWages}
          <span className="unit-custom">元</span></span>}>应发工资</Item>
          <Item extra={<span>{tenantInfo.paidWages}
          <span className="unit-custom">元</span></span>}>已发工资</Item>
          <Link to={`/manager/project/addSettlement`}><Item extra={<span>{tenantInfo.income}
          <span className="unit-custom">元</span></span>}  arrow="horizontal">结算金额
          </Item></Link>
        </List>
        <WhiteSpace />
        <List>
          <Link to={`/manager/project/settlementList`}><Item arrow="horizontal">结算明细</Item></Link>
          <Link to={`/manager/dayStatistics`}><Item arrow="horizontal">日统计明细</Item></Link>
          <Link to={`/manager/monthStatistics`}><Item arrow="horizontal">月统计明细</Item></Link>
        </List>
        <WhiteSpace />
        <WingBlank>
          <Button type="warning" onClick={this.loginOut}>退出登录</Button>
        </WingBlank>
      </div>
    )
  }
}
export default Center